using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;

namespace OgilvyOne.Utility
{
    public class FileUtil
    {
        // Methods
        private FileUtil()
        {
        }

        public static string GetUploadPath()
        {
            return "/pub/crm/uploadfiles/";
        }

        public static string SaveThrumPic(string src)
        {
            int num3;
            int num4;
            Image image = Image.FromFile(src);
            int width = image.Width;
            int height = image.Height;
            if (width > height)
            {
                if (width > 100)
                {
                    num3 = 100;
                    decimal d = (decimal.Parse(image.Height.ToString()) / decimal.Parse(image.Width.ToString())) * num3;
                    num4 = int.Parse(Math.Round(d, 0).ToString());
                }
                else
                {
                    num3 = image.Width;
                    num4 = image.Height;
                }
            }
            else if (height > 100)
            {
                num4 = 100;
                decimal num6 = (decimal.Parse(image.Height.ToString()) / decimal.Parse(image.Width.ToString())) * num4;
                num3 = int.Parse(Math.Round(num6, 0).ToString());
            }
            else
            {
                num3 = image.Width;
                num4 = image.Height;
            }
            string str = src.Substring(src.Length - src.LastIndexOf(@"\"), (src.Length - src.LastIndexOf(@"\")) - 4) + "_small." + src.Substring(src.Length - 3, 3);
            string filename = src.Substring(src.Length - src.LastIndexOf(@"\")) + str;
            image.GetThumbnailImage(num3, num4, null, IntPtr.Zero).Save(filename, ImageFormat.Jpeg);
            image.Dispose();
            return str;
        }

    }
}
